// pages/idEmail/idEmail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    err: false,
    errTxt: "邮箱不正确，请重新输入",
    email: "",//邮箱value值
    code: ""//验证码value值
  },
  emailfocus(){
    this.setData({
      err: false
    })
  },
  //email失去焦点事件
  emailBlur(e){
    console.log(e)
    let that = this;
    let regExp = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/;
    if(!regExp.test(e.detail.value)){
      that.setData({
        err: true,
        email: e.detail.value
      })
    }
  },
  //验证码失去焦点事件
  codeblur(e){
    this.setData({
      code: e.detail.value
    })
  },
  //提交按钮
  onSubmit(){
    let that = this;
    if(that.data.code && that.data.email){
      wx.showToast({
        title: '提交失败',
        icon: "none",
        duration: 1500,
        mask: true
      })
    }else{
      wx.showToast({
        title: '提交成功',
        duration: 1500,
        mask: true
      })
      setTimeout(function(){
        wx.switchTab({
          url: '/pages/index/index',
        })
      },1500)
    }
  }
})